#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
启动树形结构Neo4j查询API服务
"""

import uvicorn
import sys
import os

def main():
    """启动API服务"""
    print("🚀 启动树形结构Neo4j查询API服务")
    print("=" * 50)
    
    # 检查依赖
    try:
        import fastapi
        import neo4j
        import jieba
        print("✅ 依赖检查通过")
    except ImportError as e:
        print(f"❌ 缺少依赖: {e}")
        print("请运行: pip install -r requirements.txt")
        return
    
    # 启动服务
    try:
        uvicorn.run(
            "tree_query_api:app",
            host="0.0.0.0",
            port=8000,
            reload=True,
            log_level="info"
        )
    except KeyboardInterrupt:
        print("\n👋 服务已停止")
    except Exception as e:
        print(f"❌ 启动失败: {e}")

if __name__ == "__main__":
    main()
